<?php

namespace app\admin\model\jdy;

use think\Model;

class Task extends Model
{
    // 表名
    protected $name = 'jdy_task';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'remind_type_text',
        'task_status_text',
        'share_to_comm_text',
        'cfzq_text',
        'cfgzfw_text'
    ];
    

    
    public function getRemindTypeList()
    {
        return ['不提醒' => __('不提醒'),'一般件單日提醒' => __('一般件單日提醒'),'一般件多日提醒' => __('一般件多日提醒'),'急件' => __('急件')];
    }     

    public function getTaskStatusList()
    {
        return ['一般作業' => __('一般作業'),'緊急搶修(先請後扣)' => __('緊急搶修(先請後扣)'),'緊急搶修(請了不扣)' => __('緊急搶修(請了不扣)'),'待報價' => __('待報價'),'已報價' => __('已報價'),'待簽認' => __('待簽認'),'待備料' => __('待備料'),'待施工' => __('待施工'),'未完工' => __('未完工'),'待請款' => __('待請款'),'已出單' => __('已出單'),'已收款' => __('已收款'),'已結案' => __('已結案')];
    }     

    public function getShareToCommList()
    {
        return ['0' => __('Share_to_comm 0'),'1' => __('Share_to_comm 1')];
    }     

    public function getCfzqList()
    {
        return ['月' => __('月'),'年' => __('年')];
    }     

    public function getCfgzfwList()
    {
        return ['永不' => __('永不'),'次數' => __('次數')];
    }     


    public function getRemindTypeTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['remind_type']) ? $data['remind_type'] : '');
        $list = $this->getRemindTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getTaskStatusTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['task_status']) ? $data['task_status'] : '');
        $list = $this->getTaskStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getShareToCommTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['share_to_comm']) ? $data['share_to_comm'] : '');
        $list = $this->getShareToCommList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCfzqTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['cfzq']) ? $data['cfzq'] : '');
        $list = $this->getCfzqList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCfgzfwTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['cfgzfw']) ? $data['cfgzfw'] : '');
        $list = $this->getCfgzfwList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function anchang()
    {
        return $this->belongsTo('Anchang', 'anchang_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
